Extract color input UI into reusable ColorInput component - #440
Conversation
… variables Replace all <input type="color"> occurrences across Effects, Misc, Borders, Shadows, and Colors panels with a new ColorInput component that: - Resolves the actual displayed color via resolveColor() from the live preview iframe so swatches show the real computed value instead of hardcoded fallbacks - Accepts CSS variable syntax (var(--token)) as text input; hides the native color picker when a variable is entered since type="color" can't handle them - Clicking the swatch still opens the native picker for concrete color values, seeded with the resolved hex Also fixes TokenRow swatch to use resolveColor() so tokens whose values reference CSS variables (not in the configurator DOM scope) render correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EyxX99kENNBAiWeZvLQNBT
|
Warning Review limit reached
More reviews will be available in 52 minutes and 37 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntroduces a new reusable ChangesColorInput Component and Panel Adoption
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoExtract reusable ColorInput component for consistent token color editing Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
6 rules 1.
|
- Normalize bare "--token" input to "var(--token)" before storing or resolving so overrides emit valid CSS instead of a literal string - Extend toHex() to pass through hex strings (#RGB / #RRGGBB) so the native picker is seeded correctly when the preview resolver is not yet available - Gate TokenRow's swatchColor resolution behind type === "color" so non-color rows don't subscribe to previewVersion bumps unnecessarily Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EyxX99kENNBAiWeZvLQNBT
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@configurator/src/components/inputs/ColorInput.svelte`:
- Around line 22-30: Normalize bare custom-property values in ColorInput.svelte
before they are used by paint(), swatchColor, or saved from the input. Treat
inputs starting with -- the same as var(...) by converting them to a proper
var(--name) expression, and then use that normalized value in the derived swatch
and any save/update path so resolveColor can paint it correctly and the stored
value is a valid CSS color. Focus the fix around the paint function, the
swatchColor derivation, and the value handling used for saving.
- Around line 57-69: Escape in ColorInput.svelte is still committing changes
because the input’s blur handler runs after editing is set to false. Update the
input’s onkeydown/onblur flow so Escape cancels the draft without calling onSet
or onReset, while Enter still commits via blur; use the ColorInput component’s
editing state and blur handler to distinguish cancel vs save.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c880ab87-236f-43da-94e7-da5f19b3b1ec
📒 Files selected for processing (7)
configurator/src/components/inputs/ColorInput.svelteconfigurator/src/components/inputs/TokenRow.svelteconfigurator/src/components/panels/BordersPanel.svelteconfigurator/src/components/panels/ColorsPanel.svelteconfigurator/src/components/panels/EffectsPanel.svelteconfigurator/src/components/panels/MiscPanel.svelteconfigurator/src/components/panels/ShadowsPanel.svelte
Setting editing = false on Escape caused the input to unmount, firing blur and committing the draft value. Use a cancelBlur flag to suppress the blur handler when Escape is pressed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EyxX99kENNBAiWeZvLQNBT
Summary
Refactors repeated color picker UI patterns across multiple panels into a new reusable
ColorInputcomponent. This eliminates code duplication and provides a consistent color input experience throughout the configurator.Changes
New component:
ColorInput.svelte— a unified color input with:resolveColor()Refactored panels to use
ColorInput:MiscPanel.svelte— selection background/text, caret colorBordersPanel.svelte— border color, divider color, focus ring colorShadowsPanel.svelte— shadow color, glow colorEffectsPanel.svelte— scrim color, scrollbar thumb/trackColorsPanel.svelte— semantic color swatchesEnhanced
TokenRow.svelte— improved swatch color resolution to handle CSS variable fallbacksImplementation Details
var(...)or--*) and disables the native color picker for those cases, allowing manual entry insteadpreviewResolverto resolve and display actual computed colorshttps://claude.ai/code/session_01EyxX99kENNBAiWeZvLQNBT
Summary by CodeRabbit
New Features
Bug Fixes